<script>
	export default {
		props: {
		    chooseIndex: {
		      type: Number,
		      default: 0
		    }
		  },
		data() {
			return {
				list: [{
						value: 0,
						label: '上午'
					},
					{
						value: 1,
						label: '下午'
					}
				],
			}
		},
		methods: {
			handleClick() {
				this.$refs.LIST.open()
			},
			changeIndex(index){
				this.chooseIndex=index
				this.$refs.LIST.close()
				
				this.$emit('updateIndex', this.chooseIndex);
			}
		}
	}
</script>

<template>
	<view>
		<uni-popup ref="LIST" type="bottom">
			<view class="list">
				<view v-for="(item,index) in list" class="item" @click="changeIndex(item.value)">
					{{item.label}}
					<view v-if="item.value==chooseIndex" class="choose">
						<uni-icons type="checkmarkempty" size="20" color="#1686ff"></uni-icons>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<style>
	.list {
		width: 100vw;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		background-color: #fff;
		height: 200px;
		border-top-left-radius: 20px;
		border-top-right-radius: 20px;
	}

	.item {
		width: 100%;
		/* background-color: aliceblue; */
		display: flex;
		flex-direction: row;
		justify-content: center;
		font-size: 20px;
		margin-bottom: 5px;

		position: relative;
	}

	.choose {
		position: absolute;
		top: 0px;
		right: 20px;
	}
</style>